/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-02-23 10:15:33
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-08-28 10:27:25
 * @FilePath: \cxl-h5\src\store\user.store.ts
 */
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const userStore = defineStore('user', () => {
    const token = ref('')
    const loginStatus = ref(false)
    //是否是管理员
    const isAdmin = ref(false)
    //登录提示状态
    const loginHintStatus = ref(false)
    //是否授权
    const isAuth = ref(false)
    //上一页的路由name
    const prevRouterName = ref('')

    const setToken = (t: string) => {
        token.value = t
    }
    const reset = () => {
        token.value = ''
        loginStatus.value = false
        isAdmin.value = false
        loginHintStatus.value = false
        isAuth.value = false
        prevRouterName.value = ''
    }
    const activeLoginHint = () => {
        loginHintStatus.value = true
    }

    return {
        token,
        loginStatus,
        isAdmin,
        loginHintStatus,
        isAuth,
        prevRouterName,
        setToken,
        reset,
        activeLoginHint
    }
})
